﻿using System;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using System.Collections.Generic;

namespace ASPItalia.ModelVirtualCasting.Fake
{
    public class CountryRepository : BaseRepository<ICountryRepository>, ICountryRepository
    {
        private List<Country> countries;

        public CountryRepository()
        {
            this.countries = new List<Country>()
            {
                new Country { CountryID = 1, CountryName = "Italia" },
                new Country { CountryID = 2, CountryName = "Francia" },
                new Country { CountryID = 3, CountryName = "Regno Unito" },
                new Country { CountryID = 4, CountryName = "Stati Uniti d'America" }
            };
        }
        public IQueryable<Country> GetAll()
        {
            return countries.AsQueryable();
        }

        public IQueryable<Country> Where(Expression<Func<Country, bool>> predicate)
        {
            return countries.AsQueryable().Where<Country>(predicate);
        }

        public long Count(System.Linq.Expressions.Expression<Func<Country, bool>> predicate)
        {
            return countries.AsQueryable().Where<Country>(predicate).Count();
        }

        public Country GetByID(int countryId)
        {
            return this.Where(c => c.CountryID == countryId).Single();
        }

				#region IReadOnlyRepository<ICountryRepository,Country> Members


				public ICountryRepository EnableLazyLoading()
				{
					throw new NotImplementedException();
				}

				public ICountryRepository DisableLazyLoading()
				{
					throw new NotImplementedException();
				}

				#endregion
		}
}
